import time

import aiohttp
import pyautogui
import asyncio

# async def test1():
#     print('test1开始')
#     await asyncio.sleep(3)
#     print('test1结束')
#
# async def test2():
#     print('test2开始')
#     await asyncio.sleep(6)
#     print('test2结束')
#
# async def main():
#     await asyncio.gather(test1(),test2())
# asyncio.run(main())


async def fetch(session,url):
    async with session.get(url) as response:
        return await response.json()

async def main():
    async with aiohttp.ClientSession() as session:
        result = await asyncio.gather(*[fetch(session,f'http://httpbin.org/get?age={i}')for i in range(1,10)])
        for r in result:
            print(r)

asyncio.run(main())
















